package cn.picclife.mwx.common.core.exception;

/**
 * @author Levi.Wang
 * 基础异常类
 * 前4位数为系统模块编号，后4位为错误代码 ,唯一
 */
public class BaseException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	/* 异常信息 */
	protected String msg;

	/* 具体异常码  */
	protected int code;

	public BaseException(int code, String msgFormat, Object... args) {
		super(String.format(msgFormat, args));
		this.code = code;
		this.msg = String.format(msgFormat, args);
	}

	public BaseException() {
		super();
	}

	public String getMsg() {
		return msg;
	}

	public int getCode() {
		return code;
	}

	public BaseException(String message, Throwable cause) {
		super(message, cause);
	}

	public BaseException(Throwable cause) {
		super(cause);
	}

	public BaseException(String message) {
		super(message);
	}
	
	@Override
    public String toString() {
        return this.getClass() + "{" +
                "code='" + code + '\'' +
                ", msg='" + getMessage() + '\'' +
                '}';
    }
}
